// import 'package:flutter/material.dart';

//配置ios样式路由  使用cupertino
import 'package:flutter/cupertino.dart';
import '../pages/tabs.dart';
import '../pages/user/login.dart';
import '../pages/user/registerFirst.dart';
import '../pages/user/registerSecond.dart';
import '../pages/user/registerThree.dart';

//dialog
import '../pages/catygory/dialog.dart';

//pageview
import '../pages/tabs/pageView.dart';
import '../pages/tabs/pageViewBuilder.dart';
import '../pages/tabs/pageViewFull.dart';
import '../pages/tabs/pageViewSwiper.dart';
import '../pages/tabs/pageViewSwiperTimer.dart';
import '../pages/tabs/pageViewKeepalive.dart';

//message
import '../pages/message/LocalKey.dart';
import '../pages/message/globalKey.dart';
import '../pages/message/currentState.dart';
import '../pages/message/animatedList.dart';

//1.配置路由
final Map _routers = {
  '/': (context) => MyTabs(),
  '/login': (context) => LoginPage(),
  '/registrFirst': (context) => RegisterFirstPage(),
  '/registrSecond': (context) => registerSecondPage(),
  '/registrThree': (context) => registerThreepage(),
  //dialog
  '/dialog': (context) => DialogPage(),
  '/pageview': (context) => PageviewPage(),
  '/pageview': (context) => PageviewPage(),
  '/pageviewBuilder': (context) => pageViewBulider(),
  '/pageViewFull': (context) => PageViewFullPage(),
  '/pageViewSwiper': (context) => PageViewSwiper(),
  '/pageViewSwiperTimer': (context) => PageViewSwiperTimer(),
  '/pageViewSwiperTimer': (context) => PageViewSwiperTimer(),
  '/pageViewKeepalive': (context) => Pageviewkeepalive(),

  //message
  '/key': (context) => LocalKeyPage(),
  '/globalKey': (context) => GlobalKeyPage(),
  '/currentState': (context) => CurrentStatePage(),
  '/currentState': (context) => CurrentStatePage(),
  '/animatedList': (context) => AnimatedListPage(),
};

// 2.配置onGenerateRoute 固定写法  相当于一个中间件 可以做权限判断
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name; //news 或者是 form  -- 命名路由名称
  final Function? pageContentBuilder =
      _routers[name]; //(context) => MyTabs(),  router里面的Funtion

  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = CupertinoPageRoute(
        builder: (context) =>
            pageContentBuilder(context, arguments: settings.arguments),
      );
      return route;
    } else {
      final Route route = CupertinoPageRoute(
        builder: (context) => pageContentBuilder(context),
      );
      return route;
    }
  }
  return null;
};
